<?php
error_reporting(0);

if(isset($argv[1])){ // Movie path is given
	$movfile = substr($argv[1], strrpos($argv[1], "/")+1);
	$movdir  = substr($argv[1], 0, strrpos($argv[1], "/"));
	$ext = strtolower(substr($movfile, strrpos($movfile, ".")+1));

	if(file_exists(str_replace($ext,"jpg",$argv[1]))){
		echo "1";
	}else if($argv[2] != ""){
		$cover = file($argv[2]);
		$coverfile = fopen(str_replace($ext,"jpg",$argv[1]),"w");
		fwrite($coverfile, implode("",$cover));
		fclose($coverfile);
	}
}
	echo '3';
?>